﻿package java_45;

import java.util.Scanner;

public class Visitor {
	String name;
	int age;
	public void shouw(){
		Scanner input =new Scanner(System.in);
		while(!"n".equals(name)){
			if (age>=18&&age<=60) {
				System.out.println(name + "的年龄为:" + age + 
						"门票为:20元\n");
			}else{
				System.out.println(name + "的年龄为:" + age + "门票免费\n");
			}
			System.out.println("请输入姓名");
			name = input.next();
			if(!"n".equals(name)){
				System.out.println("请输入年龄:");
				age = input.nextInt();
			}
		}
		System.out.println("退出程序");
	}
}





package java_45;

import java.util.Scanner;

public class InitialVistor {
public static void main(String[] args) {
	Scanner input= new Scanner(System.in);
	Visitor v = new Visitor();
	System.out.println("请输入姓名");
	v.name=input.next();
	System.out.println("请输入年龄");
	v.age=input.nextInt();
	v.shouw();
}
}




